<?php

return array(
    'controllers' => array(
        'invokables' => array(
            'Admin\Controller\AdminController' => 'Admin\Controller\AdminController',
            'Admin\Controller\UserController'  => 'Admin\Controller\UserController',
            'Admin\Controller\CategoriesController'  => 'Admin\Controller\CategoriesController',
        ),
    ),
    'admin' => array(
        'use_admin_layout' => true,
        'admin_layout_template' => 'skin/backend/µAdmin/layout'
    ),
    'navigation' => array(
        'admin' => array(),
    ),
    'router' => array(
        'routes' => array(
            'admin' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/admin',
                    'defaults' => array(
                        'controller' => 'Admin\Controller\AdminController',
                        'action' => 'index',
                    ),
                ),
                'may_terminate' => true,  
                'child_routes' => array(
                    'user' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/user',///user[/][:action][/:id]' ,
                            'constrains' => array(
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'    => '[0-9]+' ,
                            ),
                            'defaults' => array(
                                'controller' => 'Admin\Controller\UserController',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true ,
                        'child_routes' => array (
                            'create' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/create',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'create',
                                    ),
                                ),
                            ),
                            'update' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/update[/:id]',
                                    'constrains' => array(
                                        'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                        'id'    => '[0-9]+' ,
                                    ),
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'update',
                                    ),
                                ),
                                'may_terminate' => true ,
                                'child_routes' => array (

                                )
                            ),
                            'delete' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/delete[/:id]',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'delete',
                                    ),
                                ),
                            ),
                            'login' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/login',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'login',
                                    ),
                                ),
                            ),
                            'authenticate' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/authenticate',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'authenticate',
                                    ),
                                ),
                            ),
                            'lock-screen' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/lock-screen',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'lockScreen',
                                    ),
                                ),
                            ),
                            'logout' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/logout',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\UserController',
                                        'action'     => 'logout',
                                    ),
                                ),
                            ),
                        ),
                    ),
                    'categories' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/categories',///user[/][:action][/:id]' ,
                            'constrains' => array(
                                'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'    => '[0-9]+' ,
                            ),
                            'defaults' => array(
                                'controller' => 'Admin\Controller\CategoriesController',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true ,
                        'child_routes' => array (
                            'create' => array(
                                'type' => 'Literal',
                                'options' => array(
                                    'route' => '/create',
                                    'defaults' => array(
                                        'controller' => 'Admin\Controller\CategoriesController',
                                        'action'     => 'create',
                                    ),
                                ),
                            ),
                        ),
                    ),
                )
            ),
            /*
            'user' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/admin/user[/:action][/:id]',
                    'defaults' => array(
                        'controller' => 'Admin\Controller\UserController',
                        'action' => 'index',
                    ),
                ),
                'may_terminate' => true,
            ),*/
        ),
    ),
    'authorize' => array(
        'guards' => array(
            /*'Authorize\Guard\Controller' => array(
                array(
                    'controller' => array('Admin\Controller\AdminController'),
                    'action' => array('index'),
                    'roles' => array('admin')
                ),
                array(
                    'controller' => array('Admin\Controller\UserController'),
                    'action' => array('index','create','update','logout'),
                    'roles' => array('admin')
                ),
                array(
                    'controller' => array('Admin\Controller\UserController'),
                    'action' => array('login'),
                    'roles' => array('guest')
                ),
                array(
                    'controller' => array('user'),
                    'action' => array('index','logout'),
                    'roles' => array('user','admin')
                ),
                array(
                    'controller' => array('user'),
                    'action' => array('login','register'),
                    'roles' => array('guest')
                ),
            ),*/
            'Authorize\Guard\Route' => array(
                array('route' => 'admin', 'roles' => array('admin')),
                array('route' => 'admin/user', 'roles' => array('admin')),
                array('route' => 'admin/user/create', 'roles' => array('admin')),
                array('route' => 'admin/user/update', 'roles' => array('admin')),
                array('route' => 'admin/user/delete', 'roles' => array('admin')),
                array('route' => 'admin/user/login', 'roles' => array('guest')),
                array('route' => 'admin/user/logout', 'roles' => array('admin')),
                array('route' => 'admin/user/lock-screen', 'roles' => array('admin')),
                array('route' => 'admin/categories', 'roles' => array('admin')),
                array('route' => 'admin/categories/create', 'roles' => array('admin')),
                
                //array('route' => 'document', 'roles' => array('admin' , 'guest' , 'user')),
            ),
        ),
    ),
    'view_manager' => array(
        //'not_found_template'       => 'backend/error/404',
        //'exception_template'       => 'backend/error/index',
        'template_path_stack' => array(
            __DIR__ . '/../view'
        ),
    ),
);
